package com.tingyuge.base.thread.queue.arrayqueue;

import java.util.concurrent.ArrayBlockingQueue;

/**
 * Created by xiaodao
 * date: 2020/4/6
 */
public class ArrayBlockQueueTest {

    public static void main(String[] args) throws InterruptedException {
     final    ArrayBlockingQueue queue = new ArrayBlockingQueue(1);

        new Thread(()->{
            try {
                queue.put("111");
                queue.put("2323");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        }).start();
        Thread.sleep(100);
        System.out.println(queue.size());
        System.out.println(queue.take());

    /*    new Thread(()->{
            try {
                while (true){
                    Thread.sleep(2000);
                    System.out.println(queue.take());
                }
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }).start();*/
//        Thread.currentThread().join();
    }
}
